package 常用字符流;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
//BufferedReader
//缓冲字符输入流
public class BufferedReaderExample {
    public static void main(String[] args) {
        try (FileReader fileReader = new FileReader("test.txt");
             BufferedReader bufferedReader = new BufferedReader(fileReader)) {

            String line;
            int lineNumber = 1;

            // 逐行读取文件内容
            while ((line = bufferedReader.readLine()) != null) {
                System.out.println("Line " + lineNumber + ": " + line);
                lineNumber++;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}